package com.example.andylau96.res.Main;

import android.app.Fragment;
import android.app.FragmentManager;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import com.example.andylau96.res.R;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * Created by AndyLau96 on 2016/11/28.
 */
public class myCompany extends Fragment implements View.OnClickListener
{
    private ImageButton company_re;
    private LinearLayout company_title;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.my_company,container,false);
        company_re= (ImageButton) view.findViewById(R.id.company_title_return);
        company_title= (LinearLayout) view.findViewById(R.id.company_title);
        company_re.setOnClickListener(this);
        return view;
    }
    @Override
    public void onClick(View view) {
        FragmentManager fm=getFragmentManager();
        fm.popBackStack();
    }
    @Override
    public void onStart() {
        super.onStart();
        MainActivity.now=this;
        String theme=null;
        File file=new File("/data/data/com.example.andylau96.res/files/color.txt");
        try {
            InputStreamReader reader=new InputStreamReader(new FileInputStream(file),"UTF-8");
            BufferedReader br=new BufferedReader(reader);
            theme="";
            String temp=null;
            while((temp=br.readLine())!=null)
            {
                theme+=temp;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        company_title.setBackgroundColor(Color.parseColor(theme));
    }
}
